window.__IM_DONOT_AUTO_RUN__ = true;
/*
 ______                                  
/\__  _\                    __           
\/_/\ \/     ___ ___       /\_\    ____  
   \ \ \   /' __` __`\     \/\ \  /',__\ 
    \_\ \__/\ \/\ \/\ \  __ \ \ \/\__, `\
    /\_____\ \_\ \_\ \_\/\_\_\ \ \/\____/
    \/_____/\/_/\/_/\/_/\/_/\ \_\ \/___/ 
                           \ \____/      
                            \/___/      
*/

(function(host) {
  const o2s = {}.toString;
  const isFun = f => {
    return o2s.call(f) === "[object Function]";
  };
  const doc = document;
  const head = doc.getElementsByTagName("head")[0] || doc.documentElement;

  const currentScript = () => {
    return doc.currentScript;
  };
  let uid = 0;
  const uuid = () => {
    return "m-" + (++uid).toString(32);
  };
  const rfile = /[^\/]+?$/;
  const normalize = path => {
    path = path.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
    let parts = path.split("/"),
      absolute = isAbsolute(path),
      prefix = "";
    if (absolute) prefix = parts[0] ? parts.shift() + "//" : "";
    for (let i = 0; i < parts.length; ) {
      if (parts[i] === "..") {
        if (i > 0 && parts[i - 1] !== "..") parts.splice(--i, 2);
        else if (absolute) parts.splice(i, 1);
        else ++i;
      } else if (parts[i] === ".") parts.splice(i, 1);
      else ++i;
    }
    return prefix + parts.join("/");
  };
  const isAbsolute = path => {
    return /^(?:\/|\w+:)/.test(path);
  };
  const dirname = path => {
    return ("" + path).replace(rfile, "");
  };
  const filename = path => {
    return (rfile.exec("" + path) || [""])[0];
  };
  const realpath = (id, dir) => {
    dir = dir || "";
    let url = "";
    if (rfile.test(id)) {
      id = /\.js$/.test(id) ? id : `${id}.js`;
    } else {
      id = id + require.default;
    }

    if (isAbsolute(id)) {
      url = id;
    } else if (id[0] && id[0] in aliasRoots) {
      url = replaceAliasRoots(id);
    } else {
      dir = replaceAliasRoots(dir);
      url = dir ? `${dir}/${id}` : id;
    }

    return normalize(url);
  };
  const modules = {
    // 'a' : {id:'a', deps:[], factory:(function(){}), dirname, filename, export:null}
  };

  const aliasRoots = {
    get "/"() {
      const loc = window.location;
      return normalize(loc.origin + dirname(loc.pathname));
    },
    get "@"() {
      let cwd = require.cwd;
      if (isAbsolute(cwd)) {
        return cwd;
      } else {
        return normalize(aliasRoots["/"] + (require.cwd || "./"));
      }
    }
  };
  const replaceAliasRoots = (url = "") => {
    return url.replace(/^[\s\S]/, a => {
      if (a in aliasRoots) {
        return aliasRoots[a];
      } else {
        return a;
      }
    });
  };
  const define = (...args) => {
    const [id, deps, factory] = args;
    let i, d, f;
    const curScript = currentScript();
    const moduleId = curScript && curScript.$id;
    const moduleUrl = curScript && curScript.$url;
    if (args.length == 1) {
      [i, d, f] = [moduleId, [], id];
    } else if (args.length == 2) {
      [i, d, f] = [moduleId, id, deps];
    } else if (args.length == 3) {
      [i, d, f] = [id, deps, factory];
    } else {
      throw new Error("Arguments error.");
    }
    return (modules[i] = modules[i] || {
      id: i,
      uuid: uuid(),
      url: moduleUrl,
      deps: d,
      factory: f,
      dirname: dirname(moduleUrl),
      filename: filename(moduleUrl),
      time: new Date().getTime()
    });
  };
  const loadScript = (id, dir) => {
    let url = realpath(id, dir);

    return new Promise((resolve, reject) => {
      const script = doc.createElement("script");
      script.addEventListener(
        "load",
        e => {
          resolve(modules[id]);
          head && script && script.parentNode && head.removeChild(script);
        },
        { once: true }
      );
      script.addEventListener(
        "error",
        e => {
          reject(`Not Found Module: ${url}`);
        },
        { once: true }
      );
      script.$id = id;
      script.$url = url;
      script.src = url + (require.tag ? "?" + require.tag : "");
      head.insertBefore(script, head.firstChild);
    });
  };
  const hooks = {};
  const setHook = (id, factory) => {
    return (hooks[realpath(id)] = factory);
  };
  const getHook = id => {
    const url = realpath(id);
    return hooks[url] && define(id, [], hooks[url]);
  };

  const fetchModule = async (id, root, path = []) => {
    const module = modules[id] || (await loadScript(id, root)) || getHook(id);

    if (!module)
      throw new Error(
        `The module ${id} is not defined. You can define AMD module or use hook.`
      );
    // path.push(id);

    const { deps = [], factory, dirname, filename } = module;

    if (!("export" in module)) {
      module.export = await factory.apply(
        { dirname, filename },
        (await Promise.all(deps.map(did => fetchModule(did, dirname, path)))) ||
          []
      );
    }
    return module.export;
  };

  const require = async (id, callback) => {
    id = id.trim();
    let modulesExport = await fetchModule(id, require.cwd);
    isFun(callback) && callback(modulesExport);
    return modulesExport;
  };

  define.amd = true;

  host.define = define;

  host.require = require;

  require.modules = modules;

  require.default = "";

  require.cwd = "";

  require.tag = "";

  require.main = "";

  require.setHook = setHook;

  const curScript = currentScript();
  if (curScript) {
    try {
      const attr = curScript.attributes;
      ["cwd", "tag", "main", "default"].forEach(key => {
        let a;
        if ((a = attr[`data-${key}`])) {
          require[key] = a.nodeValue;
        }
      });
    } catch (e) {
      throw e;
    }
  }

  if (!window.__IM_DONOT_AUTO_RUN__ && require.main) require(require.main);
})(window);
;//../assets/js/main.js
;define('main', ["m-2","m-3","m-4","m-5","m-6","m-7"], 
        async function(
  apis,
  Favs,
  Index,
  Demo,
  Mycards,
  Game
) {

    const  { html, Component, render, linkState, Router } = preact;


    // let axios = await require('https://unpkg.com/axios/dist/axios.js');
    // let mitt = await require('https://unpkg.com/mitt/dist/mitt.umd.js');
    // let zzz = await require('https://unpkg.com/jquery@3.4.1/dist/jquery.js', ()=>{

    // });

    
    // let res = await axios.get('/')
    // console.log(res);

    class App extends Component {
        constructor(props){
          super(props)
          this.state = {
            //
            historyKey:''
          }

          console.env({title:"版本号",content: window.version})
          console.env({title:"环境",content: /^[\d\.]+$/.test(window.version) ? "正式环境":"开发环境"})
          // console.env({title:"当前appkey",content: window.env.appKey})
          // console.env({title:"当前host",content: window.env.host})


          //https://github.com/preactjs/preact-router
          //https://github.com/ReactTraining/history
          //https://github.com/ReactTraining/history/blob/master/docs/GettingStarted.md
          // this.history = Router.history.createHashHistory();
          this.history = Router.history.createMemoryHistory();


          this.history.listen((location, action) => {
            // 路由改变
            // location is an object like window.location
            // console.log(this.history, action, location.pathname, location.state);
            this.setState({
              historyKey : this.history.location.key
            })
          });


          this.updatePageType();
          
        }

        updatePageType(){
          const html = document.documentElement;
          const winheight = html.getBoundingClientRect().height;
          const deviceHeight = winheight / (window.rem/100) //lib/rem.js

          let type = 'normal';

          console.env({title:"按设计比例的实际高度", content: deviceHeight.toFixed(1)});
          
          // console.log(deviceHeight)

          if(deviceHeight < 1400){
            type = 'small'
          }else if(deviceHeight>= 1400 && deviceHeight < 1540){
            type = 'normal'
          }else{
            type = 'large'
          }

          console.env({title:"页面类型", content: type});

          this.setState({
            pageType: type
          })

        }

        async componentDidMount(){
          // if(this.history.location.pathname == "/"){
          //   Router.route('/demo', true);
          // }

          var info = Tida.appinfo;
          if(!(info.isTmall||info.isTaobao)){
              Tida.openClient( window.location.href );
          }

          let params = apis.params();
          // console.log(params);
          if(params.r){
            Router.route(`/${params.r}`, true);
          }
        }

   
        render({ }, { pageType }) {

          let props = {
            foo:"bar", history:this.history
          }

          console.log(this.history.index)

          return html`<div class="game-app page-${pageType}">

                  ${ this.history.length>0&&this.history.index!=0 ? html`<div class="goback" onclick=${()=>{
                    // console.log(this.history.index);
                    this.history.go(-1);
                  }}>返回</div>` : ''}
                  
                  <${Router} history=${this.history}>
                    <${Index} path="/"    ...${props}/>
                    <${Favs} path="/favs" ...${props}/>
                    <${Demo} path="/demo" ...${props}/>
                    <${Game} path="/game" ...${props}/>
                    <${Mycards} path="/mycards" ...${props}/>
                  <//>
              </div>
          `;
        }
      }
    
      
    render(html`<${App} />`, document.querySelector('#app'));

    return App;
})
;;//../assets/js/apis.js
;define('m-2', [], 
        function() {
    
    // console.log(window.env);//env.host

    const host = 'https://cliniques.ewszjk.m.jaeapp.com';

    const getApi = function(method){
        return `${host}/index.php?c=api&m=${method}`;
    };

    const toParam = function(data){
        var re = [];
        for (const key in data) {
            if (data.hasOwnProperty(key)) {
                re.push(`${key}=${data[key]}`);
            }
        }
        return re.join('&');
    }


    return {
        //获取用户信息
        getUserData: function(nick){
            var data={
                mixnick:nick
            }
            return axios.get(getApi('userinfo')+"&"+toParam(data))
        },
        //摇奖
        luckydraw: function(nick){
            const params = new URLSearchParams();
            params.append('mixnick', nick);
            return axios.post(getApi('luckydraw'), params)
        },
        toast(msg){
            if(Tida){
                Tida.toast(msg);
            }else{
                console.info(msg);
            }
        },
        // 分享
        share(){
            return new Promise(function(resolve, reject){
                let title = document.getElementById('WV.Meta.Share.Title');
                let content = document.getElementById('WV.Meta.Share.Text');
                let image = document.getElementById('WV.Meta.Share.Image');

                Tida.share({
                    title: title ? title.attributes.value.value : '',
                    content: content ? content.attributes.value.value : '', //分享的内容
                    url: window.location.href, // 跳转地址，分享的内容跳转的url
                    image: image ? image.attributes.value.value : '',
                }, function(data){
                    resolve(data)
                    // 分享接口调用成功，在手机淘宝下面该回调仅代表API执行成功，非分享成功与否的回调。
                });
            })
        },
        params(){
            let search = window.location.search.replace(/^\?/,'');
            let params = {};
            search.split('&').forEach(p=>{
                let s = p.split('=');
                params[s[0]] = s[1];
            })
            return params;
        }
    };
    
 })
;;//../assets/js/pages/favs/index.js
;define('m-3', [], 
        function(){

    const  { html, Component, render, linkState } = preact;

    class Index extends Component {
        constructor(props){
            super(props);
            this.state = {
            }
        }
        componentDidMount(){

        }
        render(props, state){

            return html`收藏页`;
        }
    }

    return Index;
})
;;//../assets/js/pages/index/index.js
;define('m-4', [], 
        function(){

    const  { html, Component, linkState } = preact;
  
    class Index extends Component {
        constructor(props){
            super(props);
            this.state = {
                dialogMyAwardVisible : false,
            }
        }
        componentDidMount(){

        }
        render(props, state){

            console.log('main=>props:', props);

            const gotoHref = (path)=>{
                props.history.push(path)
            }

            return html`<div class="page-index">
            <h1>hello world!</h1>
            <ul>
                <li>
                <a href="javascript:void(0);" onClick=${()=>{
                    gotoHref('/demo');
                    return false;
                }}>进入demo页</a>
                </li>
                <li>
                <a href="javascript:void(0);" onClick=${()=>{
                    gotoHref('/game');
                    return false;
                }}>进入游戏页</a>
                </li>
                <li>
                <a href="javascript:void(0);" onClick=${()=>{
                    gotoHref('/favs');
                    return false;
                }}>收藏页</a>
                </li>
                <li>
                <a href="javascript:void(0);" onClick=${()=>{
                    gotoHref('/mycards');
                    return false;
                }}>我的卡片</a>
                </li>
            </ul>
            </div>`;
        }
    }

    return Index;
})
;;//../assets/js/pages/demo/index.js
;define('m-5', ["m-8","m-9","m-a","m-b"], 
        function(
    Header, 
    Footer, 
    ReactSwipe,
    Dialog
  ) {
    const  { html, Component, render, linkState } = preact;
    class Demo extends Component {
        constructor(props){
          super(props)
          this.state = {
            todos: [],
            dialogVisible: false,
            text: 'hello'
          }
        }

        addTodo() {
            const todos = this.state.todos || [];
            this.setState({ todos: todos.concat(`Item ${todos.length}：${this.state.text}`) });
          }
       render({ }, { todos = [], dialogVisible, text }) {
            return html`
            <div class="game-app">
            <${Header} name="ToDo" />
            


            <div class="dialog-demo">
              <button class="open" onClick=${()=>this.setState({dialogVisible: true})}>open</button>
              
              <${ReactSwipe}
              className="carousel"
              style=${{overflow:'hidden', height:"300px"}}
              swipeOptions=${{ continuous: false }}
              ref=${el => {this.el = el}}
              >
                <div style=${{height: "300px"}}>PANE 1</div>
                <div style=${{height: "300px"}}>PANE 2</div>
                <div style=${{height: "300px"}}>PANE 3</div>
              <//>
              
              ${ dialogVisible && html`
                <${Dialog} 
                title="test"
                width="5rem"
                height="7rem"
                close=${()=>this.setState({dialogVisible: false})}
                footer=${html`<button onClick=${()=>this.setState({dialogVisible: false})}>确定</button>`}
                >
                  <div style="font-size:0.4rem">
                    todo
                      <ul>
                        ${todos.map(todo => html`
                          <li>${todo}</li>
                        `)}
                      </ul>
                      
                      
                      <button onClick=${this.addTodo.bind(this)}>Add Todo</button>

                      <br/>
                      <br/>
                      双向绑定：
                      <br/>
                      ${text}<br/>
                      <input value=${text} onInput=${linkState(this, 'text')} />
                    
                  </div>
                <//>
              ` }


            </div>

            <!-- <${Footer}>footer content here<//> -->

          </div>`
       }

    }


       return Demo;

  })
;;//../assets/js/pages/mycards/index.js
;define('m-6', [], 
        function(){

    const  { html, Component, render, linkState } = preact;

    class Index extends Component {
        constructor(props){
            super(props);
            this.state = {
            }
        }
        componentDidMount(){

        }
        render(props, state){

            return html`我的卡片`;
        }
    }

    return Index;
})
;;//../assets/js/pages/game/index.js
;define('m-7', ["m-b","m-c","m-2"], 
        function(Dialog, GamePixi, apis){

    const {html, Component, linkState, render} = preact;
    


    class Game extends Component{
        constructor(){
            super(...arguments)

            this.state = {
            }
        }
        
        async componentDidMount(){
            this.game = new GamePixi();
            this.game.onEnd = function(){
							//游戏结束
            }
            this.game.$com = this;

            this.loadData();
        }
        async loadData(){
            
        }
        render({ }, { 
            foo, 
          }){

            return html`<div class="page-game">
            <div id="game"></div>
            </div>`
          }
    }

    return Game;

})
;;//../assets/js/components/header.js
;define('m-8', ["m-2"], 
        function(apis) {

    const  { html, Component, render } = preact;

    // console.log("apis:", apis)

    const { getUserData } = apis;

    const Header = ({ name }) => html`<header><h1>${name} List</h1></header>`;


    return Header;

})
;;//../assets/js/components/footer.js
;define('m-9', [], 
        function() {

    const  { html, Component, render } = preact;
    
    const Footer = props => html`<footer ...${props} />`

    return Footer;
    
 })
;;//../assets/js/components/ReactSwipe.js
;define('m-a', [], 
        function() {

    const  { html, Component, render, linkState } = preact;

    const isEqual = function(A, B){
        //完美方案 使用lodash.isequal
        if(A === B){
            return true;
        }else{
            return JSON.stringify(A) === JSON.stringify(B);
        }

        console.log(A, B)
    }


    //参考 https://github.com/voronianski/react-swipe
    // https://github.com/voronianski/swipe-js-iso

    class ReactSwipe extends Component {

        constructor(props){
            super(props);
        }

        componentDidMount() {
            this.swipe = Swipe(this.containerEl, this.props.swipeOptions);
        }

        componentDidUpdate(prevProps) {
            // console.log("prevProps:", prevProps);
            const { childCount, swipeOptions } = this.props;
            const shouldUpdateSwipeInstance =
              prevProps.childCount !== childCount ||
              !isEqual(prevProps.swipeOptions, swipeOptions);
        
            if (shouldUpdateSwipeInstance) {
                console.log('swipe rerender');
              this.swipe.kill();
              this.swipe = Swipe(this.containerEl, this.props.swipeOptions);
            }
          }
        
          componentWillUnmount() {
            this.swipe.kill();
            this.swipe = void 0;
          }
        
          next() {
            this.swipe.next();
          }
        
          prev() {
            this.swipe.prev();
          }
        
          slide(...args) {
            this.swipe.slide(...args);
          }
        
          getPos() {
            return this.swipe.getPos();
          }
        
          getNumSlides() {
            return this.swipe.getNumSlides();
          }
        
          render() {
            const { id, className, style={}, styles={}, children } = this.props;

            return html`<div
                id=${id}
                ref=${el => (this.containerEl = el)}
                className=${`react-swipe-container ${className}`}
                style=${{...styles.container||{}, ...style}}
              >
                <div style=${styles.wrapper}>
                  ${children.map(child=>{
                    if (!child) {
                        return null;
                    }
                    // console.log(child.attributes);
                    const childStyle = child.attributes && child.attributes.style
                    ? { ...styles.child, ...child.attributes.style }
                    : styles.child;
                    child.attributes = {
                        ...child.attributes||{},
                        style: childStyle
                    };
                    // console.log(child);
                    return child;
                  })}
                </div>
              </div>`;
          }

    }


    ReactSwipe.defaultProps = {
      swipeOptions: {},
      styles: {
        container: {
          overflow: 'hidden',
          visibility: 'hidden',
          position: 'relative'
        },
        wrapper: {
          overflow: 'hidden',
          position: 'relative'
        },
        child: {
          float: 'left',
          width: '100%',
          position: 'relative',
          transitionProperty: 'transform'
        }
      },
      className: '',
      childCount: 0
    };


    return ReactSwipe;

})
;;//../assets/js/components/dialog.js
;define('m-b', [], 
        function() {

    const  { html, Component, render } = preact;
    
    class Dialog extends Component {

        constructor(props){
            super(props);
            this.state = {
                // hello: 'world',
                classState : ''
            }

            // console.log(this.props)

            this.close = this.close.bind(this);
        }


        componentDidMount(){
            this.setState({
                classState: 'mount'
            })
            // console.log(this);
        }

        close(){
            const self = this;
            const root = self.base;
            const close = self.props.close || (()=>{});
            close();

            // root.addEventListener("webkitAnimationEnd", (function(e) {
            //     if(e.target === root){
            //         console.log('close')
            //         close();
            //     }
            // }).bind(this), {once:true})

            // self.setState({
            //     classState: ''
            // })

        }

        render(props, state) {//props, state

            // console.log(props);
            const { 
                overlay=true,
                closebtn=true,
                header,
                footer,
                width="",
                height="",
                contentStyle={},
                close=()=>{}
            } = props;
            
            // contentStyle = {};
            width && (contentStyle.width = width);
            height && (contentStyle.height = height)

            // return ReactDOM.createPortal(
            //     this.props.children,
            //     this.el,
            //   );
            // ...${props}
            // console.log(props);

            return html`
            <div class=${'dialog '+(props.class||'')+' '+ (state.classState||'')}>
                ${overlay && html`<div class="dialog-overlay"></div>`}
                <div class="dialog-content" style=${contentStyle}>
                    <div class="dialog-common">
                        <div class="dialog-header">${header}</div>
                        <div class="dialog-body">
                            ${props.children}
                        </div>
                        <div class="dialog-footer">${footer}</div>
                    </div>
                    ${closebtn && html`<div onClick=${this.close} class="dialog-closed">X</div>`}
                </div>
            </div>
            `
        }

    }

    return Dialog;
    
 })
;;//../assets/js/pages/game/game.pixi.js
;define('m-c', ["m-2"], 
        function(apis){

    //文档和教程
    //http://pixijs.download/release/docs/index.html
    //https://github.com/Zainking/learningPixi

    class Gamepixi{

        // $com : null,   game.js 组件实例

        //resources: null,  //游戏资源

        constructor() {
            this.app = null;
            this.resources = null;

            this.config = {
                time: 39.3
            }

            this.data = {
                status: 'void', //void load wait play over
            };


            this.init();
        }

        init(){

            var html = document.documentElement;
            var hch  = html.clientHeight;
            var hcw  = html.clientWidth;

            let h = (750/hcw*hch)+18;

            // console.log(hch, hcw, h);

            let app = this.app = new PIXI.Application({
                width: 750,         // default: 800
                height: h<1150?1150:h,  // default: 600 1364 最佳1150 低于1150用1150，高于用屏幕高度
                antialias: true,    // default: false
                transparent: true, // default: false
                resolution: 1       // default: 1
            });
           
            // console.log(app)
            let game = document.querySelector('#game');
            game.innerHTML='';
            game.appendChild(app.view);
            
            app.renderer.view.style.position = "absolute";
            app.renderer.view.style.display = "block";
            // app.renderer.autoDensity = true;
            // app.renderer.resize(window.innerWidth, window.innerHeight);
            window.addEventListener('resize', function(){
                scaleToWindow(app.renderer.view, "top");
                // app.renderer.resize(window.innerWidth, window.innerHeight);
            }, false);
            scaleToWindow(app.renderer.view, "top");

            this.loader = PIXI.Loader.shared;


            this.load().then((res)=>{
                this.wait(res);
            })
						/*
            var sound2 = new Howl({
                src: ['assets/image/bg2.mp3'],
                loop: true
            });
            this.sound2 = sound2;
            document.addEventListener("visibilitychange", function(){
                if(document.hidden){
                    sound2.stop();
                }else{
                    sound2.play();
                }
            });
            */

        }

        onEnd(){
            
        }
        onStart(){

        }
        
        load(){
            
            const loader = this.loader;
            this.data.status = "load";
            
            return new Promise((resolve, reject)=>{
                if(this.resources && Object.keys(this.resources).length){
                    resolve(this.resources);
                }else{
                    loader.add(`cat`, `assets/image/cat2.jpg`)
                    // loader.add(`ca5t`, `assets/image/cat2.jpg?v=5`)
                    // loader.add(`ca3t`, `assets/image/cat2.jpg?v=2`)
                    // loader.add(`ca4t`, `assets/image/cat2.jpg?v=3`)
                    // loader.add(`ca2t`, `assets/image/cat2.jpg?v=1`)
                    // loader.add(`airship`, `https://img.alicdn.com/imgextra/i3/555657275/O1CN016Sz37V23bzxQGjoXH_!!555657275.png`)
                    // loader.add(`btn`, `https://img.alicdn.com/imgextra/i1/555657275/O1CN01xjdaMJ23bzxSenJYw_!!555657275.png`)
                    // loader.add(`bg0`, `https://img.alicdn.com/imgextra/i2/555657275/O1CN01tiljvY23bzxPl79Ay_!!555657275.png`)
                    // loader.add(`bg1`, `https://img.alicdn.com/imgextra/i2/555657275/O1CN01hMHni723bzxPSYK8J_!!555657275.png`)
                    // loader.add(`bg2`, `https://img.alicdn.com/imgextra/i1/555657275/O1CN01pFYOwy23bzxPSW6uy_!!555657275.png`)
                    // loader.add(`cloud`, `https://img.alicdn.com/imgextra/i1/555657275/O1CN01XHXyM223bzxUFKYU2_!!555657275.png`)
                    // loader.add(`label`, `https://img.alicdn.com/imgextra/i3/555657275/O1CN01FRej5K23bzxR5g5V7_!!555657275.png`)
                    // loader.add(`rule`, `https://img.alicdn.com/imgextra/i4/555657275/O1CN011y3B6023bzxQL8Uod_!!555657275.png`)

                    //loader.add({
                    //    name: 'sprites',
                    //    url: 'assets/image/sprites.json',
                    //    crossOrigin: true
                    //})

                    loader.load((loader, resources) => {
                        this.resources = resources;
                        console.log("resources:",resources);
                        resolve(resources);
                    });


                    //加载进度
                    const style = new PIXI.TextStyle({
                        align:"center",
                        fontFamily: 'Arial',
                        fontSize: 28
                    });
                    const loadingLabel = new PIXI.Text(`0%`, style);
                    loadingLabel.position.set((this.app.view.width-loadingLabel.width)/2, (this.app.view.height-loadingLabel.height)/2);
                    this.app.stage.addChild(loadingLabel);
                    if(loader.progress == 0){
                        loadingLabel.text = `0%`;
                        loadingLabel.position.set((this.app.view.width-loadingLabel.width)/2, (this.app.view.height-loadingLabel.height)/2);
                    }
                    loader.onProgress.add(() => {
                        // console.log(loader.progress)
                        let progress = parseInt(loader.progress);
                        loadingLabel.text = `${progress}%`;
                        loadingLabel.position.set((this.app.view.width-loadingLabel.width)/2, (this.app.view.height-loadingLabel.height)/2);
                    });


                }
            })

        }
        
        // 等待开始游戏
        wait(resources){

            if(this.data.status == 'wait')return 0;

            this.app.stage.removeChildren();

            if(!resources){
                resources = this.resources;
            }

            setTimeout(()=>{
                this.play();
            })
            
        }
        
        play(resources){

            // this.sound1.stop();
            

            if(this.data.status == 'play')return 0;

            this.app.stage.removeChildren();

            if(!resources){
                resources = this.resources;
            }


            const cat = new PIXI.Sprite(resources.cat.texture);

            cat.width = 250;
            cat.height = 250;
            
            this.app.stage.addChild(cat);
            
            
            //this.app.ticker.add();
        }
        
    }


    return Gamepixi;

});
    if (require.main) require(require.main);